import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    headers: {
      'type': 'password',
      'client': 'administration'
    },
    data
  })
}

export function getInfo() {
  return request({
    url: '/system/admin-user/get-user-info',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/system/admin-user/logout',
    method: 'post'
  })
}

export function getAsyncRouterMap() {
  return request({
    url: '/system/admin-permission/get-sidebar',
    method: 'get'
  })
}

export function getList(params) {
  return request({
    url: '/system/admin-user/list-page',
    method: 'get',
    params
  })
}

export function userPut(data) {
  return request({
    url: '/system/admin-user/put',
    method: 'post',
    data
  })
}


export function enable(data) {
  return request({
    url: '/system/admin-user/enable',
    method: 'post',
    data
  })
}

export function resetPwd(data) {
  return request({
    url: '/system/admin-user/reset-pwd',
    method: 'post',
    headers: {
      notify: false
    },
    data
  })
}

export function get(userId) {
  return request({
    url: '/system/admin-user/get',
    method: 'get',
    params: { 'userId': userId }
  })
}

export function allocationDept(userId, deptId) {
  return request({
      url: '/system/admin-user/allocation-dept',
      method: 'post',
      data: { 'userId': userId, 'deptId': deptId }
  })
}

export function allocationRoles(userId, roles) {
  return request({
      url: '/system/admin-user/allocation-roles',
      method: 'post',
      data: { 'userId': userId, 'roles': roles }
  })
}

